home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
direct1a
/
form1.frm
< prev
Wrap
Text File
|
1999-10-10
|
3KB
|
103 lines
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 4 'Fixed ToolWindow
Caption = "LRS - Directory Creator"
ClientHeight = 1710
ClientLeft = 45
ClientTop = 285
ClientWidth = 3390
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1710
ScaleWidth = 3390
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.TextBox Text4
Height = 285
Left = 1440
TabIndex = 3
Top = 840
Width = 1815
End
Begin VB.TextBox Text3
Height = 285
Left = 1440
TabIndex = 2
Top = 480
Width = 1815
End
Begin VB.TextBox Text2
Height = 285
Left = 1440
TabIndex = 1
Top = 120
Width = 1815
End
Begin VB.CommandButton Command1
Caption = "Create"
Height = 495
Left = 120
TabIndex = 0
Top = 120
Width = 1215
End
Begin VB.Label Label1
Alignment = 2 'Center
Height = 255
Left = 120
TabIndex = 4
Top = 1320
Width = 3135
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'######################################################
'# This program shows how to create nested directories
'# even if one of the directories in the path already
'# exists!
'######################################################
Private Sub Command1_Click()
CreateNewDirectory "C:\" & Text2.Text & "\" & Text3.Text & "\" & Text4.Text
Label1.Caption = "Created: C:\" & Text2.Text & "\" & Text3.Text & "\" & Text4.Text
Text4.Text = ""
Text4.SetFocus 'So you can make more subdirectories
'Here the program can proceed to save a file in whichever folder is indicated.
End Sub
Sub CreateNewDirectory(DirName As String)
Dim NewLen As Integer
Dim DirLen As Integer
Dim MaxLen As Integer
NewLen = 4
MaxLen = Len(DirName)
If Right$(DirName, 1) <> "\" Then
DirName = DirName + "\"
MaxLen = MaxLen + 1
End If
On Error GoTo DirError
MakeNext:
DirLen = InStr(NewLen, DirName, "\")
MkDir Left$(DirName, DirLen - 1)
NewLen = DirLen + 1
If NewLen >= MaxLen Then
Exit Sub
End If
GoTo MakeNext
DirError:
Resume Next
End Sub